package com.bor.gb.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * Created by bor on 12/19/14.
 */
@Component
public class BeanManager {

    @Autowired
    private ApplicationContext appContext;

    private static BeanManager instance;

    @PostConstruct
    private void setup(){
        synchronized (this){
            if (instance == null){
                instance = this;
            }
        }
    }

    public static <T> T getBean(java.lang.Class<T> aClass){
        return instance.appContext.getBean(aClass);
    }

}
